#ifndef HVTCPSERVER_H
#define HVTCPSERVER_H

#include <QObject>
#include <QHash>
#include "dataprocessservice.h"

class HvTcpServer : public QObject
{
    Q_OBJECT
public:
    explicit HvTcpServer(QObject *parent = nullptr);
    virtual ~HvTcpServer();

private:

    // K:peerAddress V:DataProcessService
    QHash<QString, DataProcessService*> services;

    hv::TcpServer* server;

public:
    bool start(quint16 port);
    void stop();

private:
    void onMessage(const hv::SocketChannelPtr &channel, hv::Buffer *buf);

signals:
    void readyRead();
    void newConnection(QString);
    void newDisconnection(QString);
};

#endif // HVTCPSERVER_H
